package com.gufe.service.user.impl.community;

import com.gufe.dto.communitydto.PostDTO;
import com.gufe.entity.Post;
import com.gufe.mapper.user.community.PostMapper;
import com.gufe.service.user.community.PostService;
import com.gufe.vo.communityvo.PostVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PostServiceImpl implements PostService {

    @Autowired
    private PostMapper postMapper;

    // 获取帖子数据
    public List<PostVO> getPosts() {
        return postMapper.getPosts();
    }

    // 根据ID获取帖子详情信息
    public PostVO getPostById(Integer id) {
        return postMapper.getPostById(id);
    }

    // 新增帖子
    public void savePost(PostDTO postDTO) {
        Post post = new Post();
        BeanUtils.copyProperties(postDTO,post);
        postMapper.savePost(post);
    }
}
